package aad.storyboard.controller;

import aad.storyboard.model.AnimationProvider;
import aad.storyboard.model.Scene;
import aad.storyboard.model.Story;
import aad.storyboard.view.NextButton;
import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;

//Command pattern: is triggered by the NavigationOnClickListener if the NextButton is clicked
public class NextNavigator implements NavigateCommand{
	
	private int position=0;
	Scene nextScene=null;
	AudioPlayer player=AudioPlayer.getInstance();
	private Activity activity;
	private NextButton btn;
	
	public NextNavigator(Activity a)
	{
		this.activity=a;
		btn=GUIComposer.getInstance().getNextButton();
	}

	/**
	 * retrieves the next scene from the story and starts the story from this point
	 */
	@Override
	public void navigate() {		
		nextScene=Story.getInstance().getCurrentChapter().getNextScene();
		
		if(nextScene!=null){	
			btn.setClickable(true);
			btn.setVisibility(1);
			//AnimationProvider.getInstance().stopAllActiveAnimations();
			ControllerManager.getInstance().startStory(nextScene);
		}
		else
		{
			btn.setClickable(false);
			btn.setVisibility(0);
			btn.postInvalidate();
		}		
		
	}


	}
